www.gusucode.com > VC 自编SQL数据库(服务端+客户端) > VC 自编SQL数据库(服务端+客户端)/code/www.NewXing.com/sql/Client/FileTree.cpp
// FileTree.cpp : implementation file // #include "stdafx.h" #include "Client.h" #include "FileTree.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CFileTree CFileTree::CFileTree() { } CFileTree::~CFileTree() { } BEGIN_MESSAGE_MAP(CFileTree, CTreeCtrl) //{{AFX_MSG_MAP(CFileTree) ON_WM_RBUTTONDOWN() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CFileTree message handlers void CFileTree::SetMenuID(UINT nID) { m_menuID = nID; } UINT CFileTree::GetMenuID() { return m_menuID; } void CFileTree::OnRButtonDown(UINT nFlags, CPoint point) { CTreeCtrl::OnRButtonUp(nFlags, point); HTREEITEM hItem = HitTest(point, &nFlags); CTreeCtrl::Select( hItem, TVGN_CARET ); CRect Rect; GetItemRect(hItem, Rect, TRUE); if( point.x>=Rect.left && point.x<=Rect.right ) { GetClientRect(Rect); ClientToScreen(Rect); point.Offset(Rect.TopLeft()); CMenu menu; if( !GetParentItem( hItem ) ) //VERIFY(menu.LoadMenu(m_menuID)); return ; else if( !GetParentItem( GetParentItem( hItem ) ) ) VERIFY(menu.LoadMenu(m_menuID)); else return; CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner); } }